// 商品调接口的模块
// 引入我们需要的地址（接口地址）
import {businessUrl} from "../config/env";
// 引入axios对象
import request from "../config/axios";
export const storeproductrulelist =(data)=>request({
    // 当入参data 没有效果 我们就要考虑是不是url的参数拼接
    url:`${businessUrl}store/product/rule/list?keywords=${data.keywords}&limit=${data.limit}&page=${data.page}`,//后端地址
    method:"GET",
    // data:{
    //     keywords:data.keywords,
    //     limit:data.limit,
    //     page:data.page
    // }
})
// 新增规格
export const storeproductrulesave =(data)=>request({
    url:`${businessUrl}store/product/rule/save`,
    method:"post",
    data
})
// 商品管理的头部 product/tabs/headers
export const producttabsheaders = ()=>request({
    url:`${businessUrl}store/product/tabs/headers`,
    method:"get",
})
// 传数据一般来说是data传出
// 如果data传出给后端发现无效我们采取url拼接
//商品管理的列表 store/product/list
export const storeproductlist = (data)=>request({
    url:`${businessUrl}store/product/list?cateId=${data.cateId}&keywords=${data.keywords}&limit=${data.limit}&page=${data.page}&type=${data.type}`,
    method:"get"
})
// 分类的树结构图 category/list/tree   status -1  type 1
export const categorylisttree = (data)=>request({
    url:`${businessUrl}category/list/tree?status=${data.status}&type=${data.type}&name=${data.name}`,
    method:"get"
})

// 导出 export/excel/product 
export const exportexcelproduct =(data)=>request({ 
    url:`${businessUrl}export/excel/product?cateId=${data.cateId}&keywords=${data.keywords}&type=${data.type}`,
    method:"get"

})
// store/product/delete 加入回收站
export const storeproductdelete = (data)=>request({
    url:`${businessUrl}store/product/delete/${data.id}?type=recycle`,
    method:"get"
})
// http://47.116.74.106:8080/api/admin/category/list/tree?status=-1&type=1

// 新增分类
export const categorysave = (data)=> request({
    url:`${businessUrl}category/save?name=${data.name}&pid=${data.pid}&sort=${data.sort}&status=${data.status}&type=${data.type}&url=url`,
    method:"POST"
})

// 编辑分类
// update?name=qweqwe&pid=718&sort=1&status=false&type=2&url=url&id=781
export const categoryupdate = (data) =>request({
    url:`${businessUrl}category/update?name=${data.name}&pid=${data.pid}&sort=${data.sort}&status=${data.status}&type=${data.type}&url=url&id=${data.id}`,
    method:"POST"
}) 

//删除分类 http://47.116.74.106:8080/api/admin/category/delete?id=720
export const categorydelete=(data)=>request({
    url:`${businessUrl}category/delete?id=${data.id}`,
    method:"get"
})

// /api/admin/system/attachment/list
// page=3&limit=10&pid=0&attType=jpg,jpeg,gif,png,bmp,PNG,JPG&temp=1667543507

export const systemattachmentlist=(data)=>request({
    url:`${businessUrl}system/attachment/list?page=${data.page}&limit=${data.limit}&pid=${data.pid}&attType=${data.attType}`,
    method:"get"
})

// 图片上传 /upload/image?model=content&pid=0
export const uploadimage =(data,params)=>request({
    url:`${businessUrl}upload/image`,
    method:"POST",
    data,//表单数据
    params//携带数据
})

// 图片移至 system/attachment/move
export const systemattachmentmove =(data)=>request({
    url:`${businessUrl}system/attachment/move`,
    method:"POST",
    data
})

// 删除图片 system/attachment/delete/
export const systemattachmentdelete = (data)=>request({
    url:`${businessUrl}system/attachment/delete/${data}`,
    method:"GET"//GET POST DELETE PUT
})

// 运费模板 express/shipping/templates/list
export const expressshippingtemplateslist = ()=>request({
    url:`${businessUrl}express/shipping/templates/list?page=1&limit=${9999999}`,
    method:"GET"
})
//保存运费 /express/shipping/templates/save
export const expressshippingtemplatessave = (data)=>request({
    url:`${businessUrl}express/shipping/templates/save`,
    method:"POST",
    data
})
// 新增商品 store/product/save
export const storeproductsave = (data) =>request({
    url:`${businessUrl}store/product/save`,
    method:"POST",
    data
})